import React from 'react'
import { Badge, TabBar } from 'antd-mobile'
import {
    AppOutline,
    MessageOutline,
    MessageFill,
    UnorderedListOutline,
    UserOutline,
    PlayOutline
} from 'antd-mobile-icons'
import { useLocation, useNavigate } from 'react-router-dom'
import style from './tabbar.module.css'

function tabbar() {
    const tabs = [
        {
            key: '/home',
            title: '首页',
            icon: <AppOutline />,
            badge: Badge.dot,
        },
        {
            key: '/circle',
            title: '康友圈',
            icon: <UnorderedListOutline />,
            badge: '5',
        },
        {
            key: '/liveVideo',
            // title:'医生直播',
            icon: <div className={style.zhibobtn} >
                <PlayOutline style={{ fontSize: '20px' }} />
                医生直播
            </div>
        },
        {
            key: '/kepu',
            title: '科普',
            icon: () =>
                <MessageFill />,
            badge: '99+',
        },
        {
            key: '/my',
            title: '我的',
            icon: <UserOutline />,
        },
    ]

    const nav = useNavigate()
    const location = useLocation()
    const changeTab = (key) => {
        nav(key)
    }
    return (
        <div className={style.tabbar}>
            <TabBar onChange={changeTab} activeKey={location.pathname}>
                {tabs.map(item => (
                    <TabBar.Item style={{ height: '60px' }} key={item.key} icon={item.icon} title={item.title} />
                ))}
            </TabBar>
        </div>
    )
}

export default tabbar
